package com.clstu.exception_;

public class ThrowException {
    public static void main(String[] args) {
        try{
            RunExceptionDemo.methodA();
        }catch (Exception e){
            System.out.println(e.getMessage());
        }
        RunExceptionDemo.methodB();//会被执行，异常被try—catch处理之后后续语句继续执行，被默认throw后后续语句不执行，程序终止
    }
}
class RunExceptionDemo{
    public static void methodA(){
        try{
            System.out.println("进入方法A");
            throw new RuntimeException("制造异常");//手动抛出异常，不像throws是使用在方法体之前
        }finally {
            System.out.println("A方法的finally ...");
        }
    }

    public static void methodB(){
        try{
            System.out.println("进入方法b");
            return;
        }finally {
            System.out.println("B的finally...");
        }
    }
}